home *** CD-ROM | disk | FTP | other *** search
- Components.utils.import("resource://yoono/yoonoService.js");
- Components.utils.import("resource://yoono/yoonoBkmSync.js");
- Components.utils.import("resource://yoono/yoonoLog.js");
- const YNPREFBRANCH = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.yoono.");
- Components.utils.import("resource://yoono/yoonoDialogs.js");
-
- var gStrbundle;
- var serverUrl;
- var bmView = null;
- var privateMarker = 'yoonoPrivate';
-
- function log(m) {
- var console = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
- console.logStringMessage(m);
- }
-
- function init() {
- try {
- log('init');
- var ua = navigator.userAgent.toLowerCase();
- if(ua.indexOf('mac os')!=-1) {
- privateMarker = 'yoonoMacPrivate';
- }
- bmView = document.getElementById("bookmarks-view")||null;
- gStrbundle=document.getElementById("yoono-strings");
- serverUrl = YOONO_PREFS.get('serverurl');
- createYoonoCustomView();
- attachYoonoBkmMenu('sidebar');
- log('ok!');
- } catch(e) {
- log(e);
- }
- }
-
- function createYoonoCustomView() {
-
- var view = {
- oldView: {},
-
- /* nsISupports */
- QueryInterface: function (aIID) {
- if (Components.interfaces.nsITreeView.equals(aIID) ||
- Components.interfaces.nsIClassInfo.equals(aIID) ||
- Components.interfaces.nsISupportsWeakReference.equals(aIID) ||
- Components.interfaces.nsISupports.equals(aIID))
- return this;
- throw Components.results.NS_NOINTERFACE;
- },
- /* nsIClassInfo */
- getInterfaces: function getInterfaces(count) {
- count.value = 4;
- return [Components.interfaces.nsITreeView,
- Components.interfaces.nsIClassInfo,
- Components.interfaces.nsISupportsWeakReference,
- Components.interfaces.nsISupports];
- },
-
- getHelperForLanguage: function getHelperForLanguage(language) { return null; },
-
- get contractID() { return null; },
- get classDescription() { return "yonooTreeView"; },
- get classID() { return null; },
- get implementationLanguage() { return
- Components.interfaces.nsIProgrammimgLanguage.JAVASCRIPT; },
- get flags() { return
- Components.interfaces.nsIClassInfo.MAIN_THREAD_ONLY |
- Components.interfaces.nsIClassInfo.DOM_OBJECT; },
-
- /* nsITreeView methods go here */
-
- get rowCount() { return this.oldView.rowCount },
-
- canDrop: function(index, orientation) { return this.oldView.canDrop(index, orientation); },
- cycleCell: function (row, col) {this.oldView.cycleCell(row, col);},
- cycleHeader: function (col) {this.oldView.cycleHeader(col);},
- drop: function (row, orientation) {this.oldView.drop(row ,orientation);},
-
- getCellProperties: function (index, column, prop) {
- if (null == bmView)
- bmView = document.getElementById("bookmarks-view");
- this.oldView.getCellProperties(index,column,prop);
- var resource = bmView.tree.builder.getResourceAtIndex(index);
- if (YOONO_BKM.isPrivate(resource.Value)) {
- var aserv=Components.classes["@mozilla.org/atom-service;1"].getService(Components.interfaces.nsIAtomService);
- prop.AppendElement(aserv.getAtom(privateMarker));
- }
- },
-
- getCellText: function(row, col) {return this.oldView.getCellText(row, col);},
- getCellValue: function(row, col) {return this.oldView.getCellValue(row, col);},
- getColumnProperties: function(col, properties) {this.oldView.getColumnProperties(col, properties);},
- getImageSrc: function(row, col) {return this.oldView.getImageSrc(row, col);}, //
- getLevel: function(index) {return this.oldView.getLevel(index);}, //
- getParentIndex: function(rowIndex) {return this.oldView.getParentIndex(rowIndex);}, //
- getProgressMode: function(row , col) {return this.oldView.getProgressMode(row , col);},
- getRowProperties: function(index, properties) {this.oldView.getRowProperties(index , properties);}, //
- hasNextSibling: function(rowIndex, afterIndex) {return this.oldView.hasNextSibling(rowIndex, afterIndex);},
- isContainer: function(index) {return this.oldView.isContainer(index);}, //
- isContainerEmpty: function(index) {return this.oldView.isContainerEmpty(index);},
- isContainerOpen: function(index) {return this.oldView.isContainerOpen(index);},
- isEditable: function(row, col) {return this.oldView.isEditable(row, col);},
- isSeparator: function(index) {return this.oldView.isSeparator(index);}, //
- isSorted: function() {return this.oldView.isSorted();},
- performAction: function(action) {this.oldView.performAction(action);},
- performActionOnCell: function(action, row, col) {this.oldView.performActionOnCell(action, row, col);},
- performActionOnRow: function(action, row) {this.oldView.performActionOnRow(action, row);},
- selectionChanged: function() {this.oldView.selectionChanged();},
- setCellText: function(row, col, value) {this.oldView.selectionChanged(row, col, value);},
- setCellValue: function(row , col , value) {this.oldView.setCellValue(row, col, value);},
- setTree: function(tree) {this.oldView.setTree(tree);},
- toggleOpenState: function(index){this.oldView.toggleOpenState(index);}
- };
-
- var mytree = bmView.tree;
- view.oldView = mytree.view;
- mytree.view = view;
-
-
- }
-
- function selectedBkm() {
- if (PlacesUtils) { // FF3
- var view = document.getElementById("bookmarks-view");
- return view.selectedNode.itemId;
- } else { // FF2
- var tree = bmView.tree;
- var selection = tree.view.selection;
- var currentIndex=selection.currentIndex;
- var resource = tree.builder.getResourceAtIndex(currentIndex);
- return resource.Value;
- }
- }
-
- window.addEventListener("load", function() { init(); }, false);
-